/**
 * Created by zhonghui on 2017/6/27.
 */
'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform', 'validate', 'validate.en', 'datetimepicker'], function ($) {
    return {
        init: function () {
            this.initPage();
            this.search();
        },

        initPage: function () {

            var $thr = $('table thead tr');
            var $checkAllTh = $('checkAll');
            $thr.prepend($checkAllTh);
            var $checkAll = $thr.find('input');

            $checkAll.click(function (event) {
                $tbr.find('input').prop('checked', $(this).prop('checked'));
                if ($(this).prop('checked')) {
                    $tbr.find('input').parent().parent().addClass('warning');
                } else {
                    $tbr.find('input').parent().parent().removeClass('warning');
                }
                event.stopPropagation();
            });

            $checkAllTh.click(function () {
                $(this).find('input').click();
            });

            var $tbr = $('table tbody tr');
            var $checkItemTd = $('checkItem');

            $tbr.prepend($checkItemTd);

            $tbr.find('input').click(function (event) {
                $(this).parent().parent().toggleClass('warning');
                $checkAll.prop('checked', $tbr.find('input:checked').length == $tbr.length ? true : false);
                event.stopPropagation();
            });

            $tbr.click(function () {
                $(this).find('input').click();
            });
        },
        search: function () {
        	var elected = $('input[name="elected"]').val().trim();
        	var checked = $('input[name="checked"]').val().trim();
        	var declared = $('input[name="declared"]').val().trim();
        	var qualified = $('input[name="qualified"]').val().trim();
        	
        	$(document).on("click", 'input[type="checkbox"]', function() {})

        }

    }
})

